package reflect;

import java.lang.reflect.Constructor;

public class ReflectDemo3 {
    public static void main(String[] args) throws Exception {
        Person p=new Person("安妮");
        System.out.println(p);


        Class cls=Class.forName("reflect.Person");

        Constructor c1=cls.getConstructor(String.class);
        Object o1=c1.newInstance("茜茜");
        System.out.println(o1);


        Constructor c2=cls.getConstructor(String.class,int.class);
        Object o2=c2.newInstance("蛋蛋",32);
        System.out.println(o2);

    }
}
